package com.dhl.demeter;

import java.util.ArrayList;
import java.util.List;

/**
 * @title: Demeter
 * @Author danghailiang
 * @Date: 2022/7/25 22:55
 * @Version 1.0
 */
public class Demeter {
    public static void main(String[] args) {
        ColManager colManager = new ColManager();
        StuManager stuManager = new StuManager();
        stuManager.printAllManager(colManager);
    }
}
// 学校管理
class StuBean{
    private int id;

    public StuBean(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}
// 学院管理
class ColBean{
    private int id;

    public ColBean(int id) {
        this.id = id;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }
}

class ColManager{
    public List<ColBean> getAllColBean(){
        List<ColBean> colBeans = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            ColBean colBean = new ColBean(i);
            colBeans.add(colBean);
        }
        return colBeans;
    }
}

class StuManager{

    public List<StuBean> getAllStuBean(){
        List<StuBean> stuBeans = new ArrayList<>();
        for (int i = 0; i < 10; i++) {
            StuBean stuBean = new StuBean(i);
            stuBeans.add(stuBean);
        }
        return stuBeans;
    }

    /**
     * 1.ColManager不是StuManager的直接朋友
     * 2.ColManager以局部变量的方式出现在StuManager
     * 3.违反了迪米来法则
     * @param colManager
     */
    public void printAllManager(ColManager colManager){
        colManager.getAllColBean().forEach(colBean -> System.out.println("学院教师id" + colBean.getId()));
        this.getAllStuBean().forEach(stuBean -> System.out.println("学校教师id" + stuBean.getId()));
    }
}

